# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgbase=python-service-identity
pkgname=('python-service-identity' 'python2-service-identity')
pkgver=17.0.0
pkgrel=2
pkgdesc="Service identity verification for pyOpenSSL"
arch=('any')
license=('MIT')
url="http://pypi.python.org/pypi/service_identity"
makedepends=('python-pyopenssl' 'python2-pyopenssl' 'python-pyasn1' 'python2-pyasn1'
             'python-setuptools' 'python2-setuptools' 'python-pyasn1-modules' 'python2-pyasn1-modules'
             'python-attrs' 'python2-attrs' 'python-idna' 'python2-idna')
checkdepends=('python-pytest-runner' 'python2-pytest-runner')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/pyca/service_identity/archive/$pkgver.tar.gz")
sha512sums=('3824cb473420a5ce6779fd35ff931189ed68286ad1f7f2936e3253a785cd76a77bbb95210a4a5fde1b1ef0c8d9c762b8e89ab44dce60ee43e34b2553ab78b5aa')

prepare() {
  cp -a service_identity-$pkgver{,-py2}
}

build() {
  cd "$srcdir"/service_identity-$pkgver
  python setup.py build
 
  cd "$srcdir"/service_identity-$pkgver-py2
  python2 setup.py build
}

check() {
  cd "$srcdir"/service_identity-$pkgver
  python setup.py pytest

  cd "$srcdir"/service_identity-$pkgver-py2
  python2 setup.py pytest
}
 
package_python-service-identity() {
  depends=('python-pyopenssl' 'python-pyasn1' 'python-pyasn1-modules' 'python-attrs')
  optdepends=('python-idna: for Internationalized Domain Names support')
 
  cd service_identity-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
 
package_python2-service-identity() {
  depends=('python2-pyopenssl' 'python2-pyasn1' 'python2-pyasn1-modules' 'python2-attrs')
  optdepends=('python2-idna: for Internationalized Domain Names support')
 
  cd service_identity-$pkgver-py2
  python2 setup.py install --root="$pkgdir" --optimize=1 --skip-build
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
